import { client } from '@/utils/client';
import request from '@/utils/request';

// 登录
export function login(data: Record<string, any>) {
	return request.post({
		url: '/login/account',
		data: { ...data, terminal: client },
	});
}

//注册
export function register(data: Record<string, any>) {
	return request.post({
		url: '/login/register',
		data: { ...data, channel: client },
	});
}

//向微信请求code的链接
export function getWxCodeUrl() {
	return request.get({ url: '/login/codeUrl', data: { url: location.href } });
}

export function OALogin(data: Record<string, any>) {
	return request.post({ url: '/login/oaLogin', data });
}

export function mnpLogin(data: Record<string, any>) {
	return request.post({ url: '/login/mnpLogin', data });
}

//更新微信小程序头像昵称
export function updateUser(data: Record<string, any>, header: any) {
	return request.post({ url: '/login/updateUser', data, header });
}

//小程序绑定微信
export function mnpAuthBind(data: Record<string, any>) {
	return request.post({ url: '/login/mnpAuthBind', data });
}

//公众号绑定微信
export function oaAuthBind(data: Record<string, any>) {
	return request.post({ url: '/login/oaAuthBind', data });
}

// 获取价格
export function getPrice() {
	return request.get({ url: '/index/getPrice' });
}

// 创建订单
export function createOrder(data = {}) {
	return request.post({ url: '/index/orderCreate', data }, { isAuth: true });
}

// 订单详情
export function orderDetail(orderId: any) {
	return request.get(
		{ url: '/index/orderDetail?pay_id=' + orderId },
		{ isAuth: true }
	);
}

// 订单列表
export function orderLists() {
	return request.get({ url: '/index/orderLists' });
}
